﻿<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<c:set var="path" value="${pageContext.request.contextPath }" />
<!DOCTYPE html>
<html>
<head>
	<meta charset="UTF-8">
	<title>变频器设备录入</title>
	<meta name="viewport"  content="width=device-width, initial-scale=1">
	<link rel="stylesheet" type="text/css" href="${path}/resource/plugins/bootstrap/css/bootstrap.min.css">
  	<link rel="stylesheet" type="text/css" href="${path}/resource/css/ysrmain.css">
    <link rel="stylesheet" href="${path}/resource/css/gzfx.css">	    
    <link rel="stylesheet" href="${path}/resource/css/records.css">
    <link rel="stylesheet" type="text/css" href="${path}/resource/plugins/date/bootstrap-datetimepicker.min.css" >
    <script type="text/javascript" src="${path}/resource/plugins/jQuery/jquery-2.2.3.min.js"></script>
	<script type="text/javascript" src="${path}/resource/plugins/bootstrap/js/bootstrap.min.js"></script>
	<script src="${path}/resource/plugins/date/bootstrap-datetimepicker.min.js" charset="UTF-8"></script>
	<script src="${path}/resource/plugins/date/bootstrap-datetimepicker.zh-CN.js" charset="UTF-8"></script>
	<script type="text/javascript" src="${path}/resource/js/echarts.min.js"></script>
</head>
<body>
	
	<!-- 头部 -->
	<!-- 开始 -->
	<jsp:include page="./top_nav.jsp"></jsp:include>
	<!-- 头部结束 -->
	
	
	
    <!-- 右侧内容区域 -->
    <div class="right-content container-fluid ">
    	<div class="row">
    		<!-- 主要图表区域 -->
            
   		<div class="head-w">变频器设备录入</div>
   		<div class="cont-condition">
   			<form id="dataForm" class="">
   				<div class="form-horizontal2">
				  	<div class="div-group4">
					    <label class="g-label">所在省份:</label>
					    <div class="g-input">
					    	<select id="province" name="province">
					    		<option value=""></option>
					    	</select>
					    </div>
				  	</div>
				  	<div class="div-group4">
					    <label class="g-label">所在城市:</label>
					    <div class="g-input">
					    	<select id="cityArea" name="cityArea">
					    		<option value=""></option>
					    	</select>
					    </div>
				  	</div>
				  	<div class="div-group4">
					    <label class="g-label">位置经度:</label>
					    <div class="g-input">
					    	<input placeholder="" id="jD" name="jD" type="text" class="input-text">
					    </div>
				  	</div>
				  	<div class="div-group4">
					    <label class="g-label">位置纬度:</label>
					    <div class="g-input">
					    	<input placeholder="" id="wD" name="wD" type="text" class="input-text">
					    </div>
				  	</div>
				  	<div class="div-group4">
					    <label class="g-label">设备型号:</label>
					    <div class="g-input">
					    	<select id="powerLevelType" name="powerLevelType">
					    		<option value=""></option>
					    	</select>
					    </div>
				  	</div>
				  	<div class="div-group4">
					    <label class="g-label">投运日期:</label>
					    <div class="g-input">
					    	<input name="operationDate" type="text" readonly="readonly" data-link-format="yyyy-mm-dd" data-link-field="dtp_input2" placeholder="请选择结束日期" class="form_date time-input2 input-text" id="datetimepicker2" data-date-format="yyyy-mm-dd ">
			     			<span class=" span-date"><span class="glyphicon glyphicon-calendar"></span></span>
					    </div>
				  	</div>
				  	
				  	
				  	<div class="div-group4">
					    <label class="g-label">设备详址:</label>
					    <div class="g-input">
					    	<input name="locationDetail" type="text" class="input-text">
					    </div>
				  	</div>
				  	<div class="div-group4">
					    <label class="g-label">设备序号:</label>
					    <div class="g-input">
					    	<input name="serialNum" type="text" class="input-text">
					    </div>
				  	</div>
				  	
				  	<div class="div-group4">
					    <label class="g-label">软件版本:</label>
					    <div class="g-input">
					    	<input name="softwareVersion" type="text" class="input-text">
					    </div>
				  	</div>
				  	<div class="div-group4">
					    <label class="g-label">用户姓名:</label>
					    <div class="g-input">
					    	<input name="userName" type="text" class="input-text">
					    </div>
				  	</div>
				  	<div class="div-group4">
					    <label class="g-label">用户电话:</label>
					    <div class="g-input">
					    	<input name="userTel" type="text" class="input-text">
					    </div>
				  	</div>
				  	<div class="div-group4">
					    <label class="g-label">用户邮箱:</label>
					    <div class="g-input">
					    	<input name="userEmail" type="text" class="input-text">
					    </div>
				  	</div>
				  	
				  	
				  	<div class="div-group4">
					    <label class="g-label">路由序号:</label>
					    <div class="g-input">
					    	<input name="fourGRouteSeriNum" type="text" class="input-text">
					    </div>
				  	</div>
				  	<div class="div-group4">
					    <label class="g-label">路由型号:</label>
					    <div class="g-input">
					    	<input name="fourGRouteType" type="text" class="input-text">
					    </div>
				  	</div>
				  	<div class="div-group4">
					    <label class="g-label">路由卡号:</label>
					    <div class="g-input">
					    	<input name="fourGRouteSIMCard" type="text" class="input-text">
					    </div>
				  	</div>
				  	<div class="div-group4">
					    <label class="g-label">IP隧道值:</label>
					    <div class="g-input">
					    	<input name="tunnelEndIP" type="text" class="input-text">
					    </div>
				  	</div>
			</div>
			<div class="text-info2">
			    <div class="form-group">
				   <textarea name="factoryCommission" class="form-control color-w" rows="3" placeholder="请录入出厂调试记录："></textarea>
				</div>
			</div>
			
		
			<div class="text-btn">
				<a class="pull-right" href="${path}/monitor/redirect/equipManage">取消 </a>
				<button class="pull-right" type="button" onclick="newAdd();">录入</button>
				
			</div>
			
			
			</form>
   		</div>
   		
   
	   </div>
    </div>
</body>
<script type="text/javascript">
$(function(){
	$(".menu-left").children("dl").eq(1).addClass("dl-active");
	
	$(".span-date").click(function(){
		$(this).prev().focus();
	})
	
	loadSelect();
})

//加载下拉框
function loadSelect() {
	$.ajax({
		type : 'POST',
		url : '<%=path%>/manage/initopt',
		data : {
			opttype : 'province'
		},
		dataType : 'json',
		async : false,
		success : function(result) {
			if(result.status == 'OK') {console.log(result);
				var html = '<option value="">——— 请选择 ———</option>';
				var ops = eval("(" + result.data.province + ")");
				$.each(ops, function(i) {
					html += ops[i].value;
				});
				$('#province').html('');
				$('#province').append(html);
			} else {
				console.error("获取下拉框数据失败！");
			}
		},
		error : function() {
			console.error("系统错误！");
		}
	});
	$.ajax({
		type : 'POST',
		url : '<%=path%>/manage/initopt',
		data : {
			opttype : 'powerLevel'
		},
		dataType : 'json',
		async : false,
		success : function(result) {
			if(result.status == 'OK') {console.log(result);
				var html = '<option value="">——— 请选择 ———</option>';
				var ops = eval("(" + result.data.powerLevel + ")");
				$.each(ops, function(i) {
					html += ops[i].value;
				});
				$('#powerLevelType').html('');
				$('#powerLevelType').append(html);
			} else {
				console.error("获取下拉框数据失败！");
			}
		},
		error : function() {
			console.error("系统错误！");
		}
	});
}
//选择省份
$('#province').change(function() {
	if($(this).val() != "" && $(this).val() != null) {
		var val = $(this).val();
		$.ajax({
			type : 'POST',
			url : '<%=path%>/manage/sltoptupdate',
			data : {
				opttype : 'cityArea',
				actval : val
			},
			dataType : 'json',
			async : false,
			success : function(result) {
				if(result.status == 'OK') {console.log(result);
					var html = '<option value="">——— 请选择 ———</option>';
					var ops = eval("(" + result.data.cityArea + ")");
					$.each(ops, function(i) {
						html += ops[i].value;
					});
					$('#cityArea').html('');
					$('#cityArea').append(html);
				} else {
					console.error("获取下拉框数据失败！");
				}
			},
			error : function() {
				console.error("系统错误！");
			}
		});
	} else {
		$('#cityArea').html('<option value=""></option>');
	}
});

function newAdd() {
	if($('input[name="serialNum"]').val() == null || $('input[name="serialNum"]').val() == '') {
		alert('设备序列号不能为空!');
		return false;
	}
	$.ajax({
		type : 'POST',
		url : '<%=path%>/monitor/managerdevAdd',
		data : $('#dataForm').serialize(),
		dataType : 'json',
		async : false,
		success : function(result) {
			if(result.status == 'OK') {
				if(result.data != null && result.data == "true") {
					alert("新增成功！");
					window.location.href = '<%=path%>/monitor/redirect/equipManage';
				} else {
					alert("新增失败！");
				}
			} else {
				alert("新增失败！");
			}
		}
	});
}

$('.form_date').datetimepicker({
    language:  'zh-CN',
    weekStart: 1,
    todayBtn:  1,
	autoclose: 1,
	todayHighlight: 1,
	startView: 2,
	minView: 2,
	forceParse: 0,
	maxView:4
});

</script>
</html>